html, body {
    margin: 0;
    padding: 0;
}

.fe-whole-page {
    width: 152px;
    min-height: 140px;
    font-size: 14px;
    user-select: none;
    padding: 0;
    margin: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: min-height 0.2s ease-out;
}

.fe-hide {
    display: none;
}

.fe-function-title {
    padding: 8px 12px;
    color: #2b2d42;
    font-weight: 600;
    cursor: default;
    border-bottom: 1px solid rgba(67, 97, 238, 0.1);
    background: linear-gradient(to right, #f8f9ff, #f0f2ff);
    font-size: 12px;
    letter-spacing: 0.5px;
    flex-shrink: 0; /* 防止被压缩 */
}

.fe-function-title span {
    font-weight: normal;
    color: #999;
    font-size: 10px;
}

ul.fe-function-list {
    padding: 0;
    list-style: none;
    width: 100%;
    margin: 0;
    flex: 1;
    min-height: 40px;
    overflow-y: auto; /* 允许垂直滚动 */
    overflow-x: hidden; /* 隐藏水平滚动 */
    max-height: 500px; /* 不再限制最大高度 */
    display: inline-table;
    scrollbar-width: thin; /* Firefox 下的滚动条样式 */
    scrollbar-color: rgba(67, 97, 238, 0.3) transparent;
}

/* 自定义滚动条样式 - Webkit内核浏览器 */
ul.fe-function-list::-webkit-scrollbar {
    width: 6px;
}

ul.fe-function-list::-webkit-scrollbar-track {
    background: transparent;
}

ul.fe-function-list::-webkit-scrollbar-thumb {
    background: rgba(67, 97, 238, 0.3);
    border-radius: 3px;
    transition: background 0.2s ease;
}

ul.fe-function-list::-webkit-scrollbar-thumb:hover {
    background: rgba(67, 97, 238, 0.5);
}

/* 暗黑模式下的滚动条 */
html[dark-mode="on"] ul.fe-function-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
}

html[dark-mode="on"] ul.fe-function-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

ul.fe-function-list li {
    padding: 2px 10px; /* 简化padding，因为图标不再绝对定位 */
    cursor: pointer;
    color: #4a4c6d;
    /* 只对安全的属性进行过渡，避免布局变化 */
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    display: flex; /* 改为flex布局 */
    align-items: center; /* 垂直居中 */
    justify-content: flex-start; /* 改为左对齐，让图标和文字左对齐 */
    height: 28px; /* 固定高度，不变化 */
    line-height: 28px;
    width: 100%; /* 使用100%宽度，让内容在容器中居中 */
    border-radius: 6px;
    margin: 2px 0; /* 固定边距，不变化 */
    border-bottom: 1px solid rgba(67, 97, 238, 0.05);
    position: relative;
    flex-shrink: 0; /* 防止被压缩 */
    box-sizing: border-box; /* 确保padding不影响总宽度 */
}

ul.fe-function-list li:last-child {
    border-bottom: none;
}

ul.fe-function-list li.x-hovered,
ul.fe-function-list li:hover {
    color: #000;
    background: rgba(67, 97, 238, 0.08);
    box-shadow: 0 2px 6px rgba(67, 97, 238, 0.08);
    /* 保持字体粗细不变，避免文字宽度变化导致布局抖动 */
    font-weight: 500;
}

ul.fe-function-list li > span.tool-name {
    display: inline-block;
    flex: 1; /* 让文字区域占据剩余空间 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 28px;
    flex-shrink: 1; /* 允许文字被压缩以显示省略号 */
    min-width: 0; /* 允许flex项目缩小到内容宽度以下 */
}

ul.fe-function-list li > b {
    width: 20px;
    height: 20px;
    /* 只对transform进行过渡，避免其他属性变化影响布局 */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.1);
    padding: 0px;
    border-radius: 50%;
    margin-right: 12px; /* 增加图标和文字之间的间距 */
    color: currentColor;
    filter: drop-shadow(0 2px 4px rgba(67, 97, 238, 0.1));
    /* 移除绝对定位，让图标作为flex项目 */
    flex-shrink: 0; /* 防止图标被压缩 */
    flex-basis: 20px; /* 设置固定基础宽度，确保所有图标对齐 */
}

/* 暗黑模式适配 */
.dark-mode .fe-function-list li > b {
    background: rgba(255,255,255,0.1);
}

ul.fe-function-list li:hover > b {
    transform: rotate(360deg);
    -webkit-transform: rotate(360deg);
}

ul.fe-function-list li i {
    color: #aaa;
    font-weight: 700;
    font-style: normal;
}

.fe-feedback {
    font-size: 13px;
    border-top: 1px solid rgba(67, 97, 238, 0.08);
    padding: 8px 16px;
    background: linear-gradient(to right, rgba(67, 97, 238, 0.05), rgba(67, 97, 238, 0.05));
    color: var(--text-color);
    opacity: 0.9;
    flex-shrink: 0; /* 防止被压缩 */
    position: relative; /* 改为相对定位 */
    width: 100%;
    box-sizing: border-box;
    margin-top: auto; /* 确保在容器底部 */
}

.fe-feedback a {
    color: #666;
    text-decoration: none;
    text-align: left;
}

.fe-feedback a:hover {
    color: #c00;
}

svg:not(:root) {
    overflow: hidden;
}

.fe-feedback svg {
    vertical-align: middle;
    display: inline-block;
    fill: currentColor;
    margin-right: 3px;
}

.fe-feedback img {
    opacity: 0.6;
    position: relative;
    top: 1px;
}
.fe-feedback a:hover img {
    opacity: 1.0;
}

.fe-feedback .x-settings {
    float: right;
    cursor: pointer;
    margin-left: 5px;
    display: inline-flex;
    align-items: center;
    color: #666;
}

.fe-feedback .x-settings:hover {
    color: #c00;
}
.fe-feedback .x-fb,
.fe-feedback .x-settings
{
    float: right;
}

/* 加载状态样式 */
.fe-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-height: 60px;
    flex: 1;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(67, 97, 238, 0.1);
    border-left: 2px solid #4361ee;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 8px;
}

.loading-text {
    color: #666;
    font-size: 12px;
    text-align: center;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 无工具状态样式 */
.fe-no-tools {
    padding: 20px;
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.no-tools-message p {
    color: #666;
    font-size: 12px;
    margin: 0 0 12px 0;
}

.install-tools-btn {
    background: #4361ee;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.install-tools-btn:hover {
    background: #3651d4;
    transform: translateY(-1px);
}

/* 暗色模式适配 */
html[dark-mode="on"] .loading-text,
html[dark-mode="on"] .no-tools-message p {
    color: #ccc;
}

html[dark-mode="on"] .loading-spinner {
    border-color: rgba(255, 255, 255, 0.1);
    border-left-color: #4361ee;
}


/* 工具列表为空时的基本样式 */
.fe-function-list:empty {
    min-height: 20px;
}

/* 1个工具时的优化 */
.fe-function-list li:only-child {
    margin: 4px 0;
    height: 32px;
    width: 100%; /* 使用100%宽度 */
}

.fe-function-list li:only-child > span.tool-name {
    line-height: 32px;
}

/* 当只有极少工具时的特殊优化 */
.very-few-tools .fe-function-list {
    padding: 6px 0;
}

.very-few-tools .fe-function-list li {
    height: 34px;
    margin: 4px 0;
    width: 100%; /* 使用100%宽度 */
}

.very-few-tools .fe-function-list li > span.tool-name {
    line-height: 34px;
}


/* 当没有工具时，优化无工具提示的显示 */
.fe-no-tools .no-tools-message {
    text-align: center;
}

/* 优化加载状态的显示 */
.fe-loading {
    justify-content: center;
    align-items: center;
    display: flex;
    height: 120px;
}
